package main.Q501_600;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class Q591_600 {
    public static void main(String[] args) {
        System.out.println("Question591：");
        System.out.println("Question592：");
        System.out.println("Question593：");
        System.out.println("Question594：最长和谐子序列");
        System.out.println("Question595：大的国家");
        System.out.println("Question596：");
        System.out.println("Question597：");
        System.out.println("Question598：");
        System.out.println("Question599：两个列表的最小索引总和");
        System.out.println("Question600：");
    }
}

class Question594{
    public static int findLHS(int[] nums) {
        Arrays.sort(nums);
        int n = nums.length, ans = 0;
        for (int i = 0, j = 0; j < n; j++) {
            while (i < j && nums[j] - nums[i] > 1) i++;
            if (nums[j] - nums[i] == 1) ans = Math.max(ans, j - i + 1);
        }
        return ans;
    }
}

class Question595{
    {
        System.out.println("select name,population,area \n" +
                "from World\n" +
                "where area>=3000000 or population>=25000000;");
    }
}

class Question599{
    public static String[] findRestaurant(String[] list1, String[] list2) {
        int sum= list2.length+list1.length;
        Map<Integer,Integer> map=new HashMap<>();
        for (int i=0;i< list1.length;i++){
            for (int j=0;j< list2.length;j++){
                if (list1[i].equals(list2[j])){
                    if ((i+j)<sum){
                        sum=i+j;
                        map.clear();
                        map.put(i,j);
                    }else if ((i+j)==sum){
                        map.put(i,j);
                    }
                }
            }
        }
        String[] result=new String[map.size()];
        int i=0;
        for (Integer integer: map.keySet()){
            result[i]=list1[integer];
            i++;
        }
        return result;
    }
}